const { contextBridge, ipcRenderer } = require('electron');

// 暴露安全的API给渲染进程
contextBridge.exposeInMainWorld('electronAPI', {
  // 录制相关
  startRecording: () => ipcRenderer.invoke('start-recording'),
  stopRecording: () => ipcRenderer.invoke('stop-recording'),
  getRecording: () => ipcRenderer.invoke('get-recording'),
  clearRecording: () => ipcRenderer.invoke('clear-recording'),
  
  // 回放相关
  startPlayback: (events, speed) => ipcRenderer.invoke('start-playback', events, speed),
  stopPlayback: () => ipcRenderer.invoke('stop-playback'),
  
  // 事件监听
  onToggleRecording: (callback) => ipcRenderer.on('toggle-recording', callback),
  onTogglePlayback: (callback) => ipcRenderer.on('toggle-playback', callback),
  
  // 获取屏幕信息
  getScreenSize: () => ipcRenderer.invoke('get-screen-size')
});
